package com.production.CoursePlatform.service;

import com.production.CoursePlatform.entity.Comment;
import com.production.CoursePlatform.mapper.CommentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService {

    @Autowired
    private CommentMapper commentMapper;

    // 新增评论
    public void createComment(Comment comment) {
        commentMapper.insertComment(comment);
    }

    // 根据dID查找评论
    public List<Comment> findCommentByCmtId(int dID) {
        return commentMapper.selectByCmtId(dID);
    }

    // 根据cmtID删除评论
    public boolean deleteComment(int cmtID) {
        return commentMapper.deleteByCmtId(cmtID) > 0;
    }

    // 更新评论
    public boolean updateComment(Comment comment) {
        return commentMapper.updateComment(comment) > 0;
    }
}
